package rbk.rours.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import rbk.rours.common.dto.FestivalIdDto;
import rbk.rours.common.dto.FestivalInfoDto;
import rbk.rours.common.utils.JsonResult;
import rbk.rours.service.user.IFestivalService;

@RestController
public class FestivalController {
    @Autowired
    IFestivalService festivalService;

    @RequestMapping(value = "/addfestival", method = RequestMethod.POST)
    public JsonResult AddFestival(@RequestBody FestivalInfoDto request) {
        try {
            return festivalService.AddFestival(request);
        } catch (Exception ex) {
            return JsonResult.errorException(ex.getMessage());
        }
    }

    @RequestMapping(value = "/updatefestival", method = RequestMethod.POST)
    public JsonResult UpdateFestival(@RequestBody FestivalInfoDto request) {
        try {
            return festivalService.UpdateFestival(request);
        } catch (Exception ex) {
            return JsonResult.errorException(ex.getMessage());
        }
    }

    @RequestMapping(value = "/getfestival", method = RequestMethod.POST)
    public JsonResult GetFestival(@RequestBody FestivalIdDto request) {
        try {
            return festivalService.GetFestival(request.getId());
        } catch (Exception ex) {
            return JsonResult.errorException(ex.getMessage());
        }
    }

    @RequestMapping(value = "/getfestivals", method = RequestMethod.POST)
    public JsonResult GetFestivalList() {
        try {
            return festivalService.GetFestivalList();
        } catch (Exception ex) {
            return JsonResult.errorException(ex.getMessage());
        }
    }

    @RequestMapping(value = "/deletefestival", method = RequestMethod.POST)
    public JsonResult DeleteFestival(@RequestBody FestivalIdDto request) {
        try {
            return festivalService.DeleteFestival(request.getId());
        } catch (Exception ex) {
            return JsonResult.errorException(ex.getMessage());
        }
    }
}
